package com.ruoyi.wechat.api;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.Camp;
import com.ruoyi.wechat.service.ICampService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

@RestController
@RequestMapping("/wechatt/camp")
public class WxCampController extends BaseController {
    @Autowired
    private ICampService campService;
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 查询营地表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Camp camp)
    {
        startPage();
        List<Camp> list = campService.selectCampList(camp);
        return getDataTable(list);
    }

    /**
     * 获取营地表详细信息
     */
    @GetMapping(value = "/{campId}")
    public AjaxResult getInfo(@PathVariable("campId") String campId)
    {
        return success(campService.selectCampByCampId(campId));
    }

    /**
     * 新增营地表
     */
    @Log(title = "营地表", businessType = BusinessType.INSERT)
    @PostMapping("/addCamp")
    public AjaxResult add(@RequestBody Camp camp)
    {
        return success(campService.insertCamp(camp));
    }

    /**
     * 修改营地表
     */
    @Log(title = "营地表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Camp camp)
    {
        return toAjax(campService.updateCamp(camp));
    }
    @PostMapping
    public AjaxResult modifyCamp(@RequestBody Camp camp){
        return  toAjax(campService.updateCamp(camp));

    }

    /**
     * 删除营地表
     */
    @Log(title = "营地表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{campId}")
    public AjaxResult remove(@PathVariable String campId)
    {
        return toAjax(campService.deleteCampByCampId(campId));
    }
}
